package com.neusoft.io;

import java.io.Serializable;

public class Student implements Comparable<Student>,Serializable{
	/*
	 *类的属性 
	 */
	//姓名
	private String stuName;
	//学号
	private String stuNum;
	//年龄
	private int stuAge;
	//性别
	private String stuSex;
	 
	public Student(String stuName,String stuNum,int stuAge,String stuSex) {
		super();
		this.stuName=stuName;
		this.stuNum=stuNum;
		this.stuAge=stuAge;
		this.stuSex=stuSex;
	}
	/*
	 *类的行为 
	 */
	/**
	 * 睡觉的行为
	 */
	public void doSleeping() {
		System.out.println(stuName+"am sleeping...");
	}
	/**
	 * 学习的行为
	 */
	public void doStuding() {
		System.out.println("I am studing...");
	}
	/**
	 * 学生比较大小的标准是年龄
	 * 
	 * @param stu  被比较的对象
	 */
	@Override
	public int compareTo(Student stu) {
		//返回三种值：负整数、零或正整数，根据此对象是小于、等于或者大于指定对象
		//返回值
		int re_i=0;
		if(this.getStuAge()>stu.getStuAge()) {
			//大于
			re_i=1;
		}else if(this.getStuAge()<stu.getStuAge()) {
			//小于
			re_i=-1;
		}else {
			//等于
			re_i=0;
		}
		return re_i*-1;
	}
	
	public String getStuName() {
		return stuName;
	}

	public void setStuName(String stuName) {
		this.stuName = stuName;
	}

	public String getStuNum() {
		return stuNum;
	}

	public void setStuNum(String stuNum) {
		this.stuNum = stuNum;
	}

	public int getStuAge() {
		return stuAge;
	}

	public void setStuAge(int stuAge) {
		this.stuAge = stuAge;
	}

	public String getStuSex() {
		return stuSex;
	}

	public void setStuSex(String stuSex) {
		this.stuSex = stuSex;
	}
	
	@Override
	public String toString() {
		return "Student [stuName=" + stuName + ", stuNum=" + stuNum + ","
				+ " stuAge=" + stuAge + ", stuSex=" + stuSex + "]";
	}
	
}
